import { Request } from '../../utils/util.js'
let request = new Request()
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  getUserInfo (res) {
    let data = res.detail
    if(data.userInfo) { //授权
      let params = {
        encryptedData: data.encryptedData,
        iv : data.iv,
        rawData: data.rawData,
        signature: data.signature
      }

      request.post('userinfo', res => { }, params)
      app.globalData.userInfo = { nickname: data.userInfo.nickName, avatar: data.userInfo.avatarUrl, sex : data.userInfo.gender}
      wx.setStorage({
        key: 'userinfo',
        data: app.globalData.userInfo,
      })
    }

    wx.navigateBack()
  },

  onLoad: function (options) {

  }
})